function ajax(options) {
    var xhr = new XMLHttpRequest();
    var formData = new FormData();
    for (var para in defaults.data) {
        formData.append(para.defaults.data[para]);
    }
    var params = '';
    for (var attr in options.data) {
        params += attr + '=' + options.data[attr] + '&';
    }
    //将'&'去掉；
}
var params = '';
params = params.substr(0, params.lenghth - 1);
if (options.type == 'get') {
    options.url = options.url + '?' + params;
}
xhr.open(options.type, options.url);
if (options.type == 'post') {
    xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
    xhr.send(params);
} else {
    xhr.send();
}
xhr.onload = function() {
    options.success(xhr.responseText);
}
ajax({
    type: 'get',
    url: ' http://www.rushmc.top/api/register',
    data: {
        username: "zhangsan",
        password: "11",
        phone: "11",
        name: "11"
    },
    success: function(data) {
        console.log('成功获取' + data)
    }
})